<?php
/**
 * Yotaku shop - yshop
 * Copyright (c) 2016 http://www.yotaku.cn All rights reserved.
 * Author: Creatint <creatint@163.com> <http://creatint.yotaku.cn>
 */
namespace Addons\Mobile;
use Common\Controller\Addon;
class MobileAddon extends Addon{


    /**
     * @describe  sending verificatoin code to user's mobile
     * @author Creatint
     * @param $mobile   mobile
     * @return bool true: sending success; false: sending failed
     */
    public function send_verification_code($params){
        //get addon configs
        $config = $this->getConfig();

        switch($config['platform']){
            case 1:
                //bmob 
                include_once 'bmob/Api.class.php';
                $Api = new \Api();
                $res = $Api->send($params['mobile'], $params['code']);
                break;
            case 2:
                break;
            case 4:
                //ihuyi
                include_once 'ihuyi/Api.class.php';
                $Api = new \Api();
                $res = $Api->send($params['mobile'], $params['code']);
                break;
            default:
                return false;
        }
        return $res;
    }

    public function check_verification_code($params){
        //get addon configs
        $config = $this->getConfig();

        switch($config['platform']){
            case 1:
                //bmob
                include_once 'bmob/Api.class.php';
                $Api = new \Api();
                $res = $Api->check($params['mobile'], $params['code']);
                break;
            case 2:
                break;
            case 4:
                //ihuyi
                $Api = new \Api();
                $res = $Api->check($params['mobile'], $params['code']);
                break;
            default:
                return false;
        }
        return $res;
    }



    public function install(){
        return true;
    }

    public function uninstall(){
        return true;
    }

}